package cn.xyinping.user.controller;

import cn.xyinping.basic.exception.MyException;
import cn.xyinping.basic.util.AjaxResult;
import cn.xyinping.user.service.IVerifycodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 27266
 * @desrciption 短信验证登陆
 * @date 2021/10/29
 */
@RestController
@RequestMapping("/verifycode")
public class VerifycodeController {
    @Autowired
    private IVerifycodeService iVerifycodeService;
    @PostMapping("/smsCode")  // 前端时post请求所以用postMapping
    public AjaxResult smsCode(@RequestBody Map<String, String> param){
        try {
            iVerifycodeService.smsCode(param); // 获取验证码
            return AjaxResult.me();
        } catch (MyException e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("系统繁忙");
        }
    }
}
